package com.chenchen.subject.application.mq;

import com.alibaba.fastjson.JSON;
import com.chenchen.subject.domain.entity.SubjectLikedBO;
import com.chenchen.subject.domain.serivice.SubjectLikedDomainService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * ClassName SubjectLikedConsumer
 * description:
 * 点赞消费
 * @author 海问香
 * @createTime 2024/9/4 9:35
 */
@Component
@RocketMQMessageListener(topic = "subject-liked",consumerGroup = "subject-liked-consumer")
@Slf4j
public class SubjectLikedConsumer implements RocketMQListener<String> {
    @Resource
    private SubjectLikedDomainService subjectLikedDomainService;
    @Override
    public void onMessage(String message) {
      log.info("SubjectLikedConsumer:onMessage:message:{}",message);
        SubjectLikedBO subjectLikedBO = JSON.parseObject(message,SubjectLikedBO.class);
        subjectLikedDomainService.syncLikedByMsg(subjectLikedBO);
    }
}
